<?php

Yii::import('usuarios.models._base.BaseTCargoaap');

class TCargoaap extends BaseTCargoaap {

    /**
     * @return TCargoaap
     */
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public static function label($n = 1) {
        return Yii::t('app', 'TCargoaap|TCargoaaps', $n);
    }

    /**
     * Metodo en l cual obtenemos unicamente los cargos disponibles para esta persona
     * y q aun no ha escogido.
     * @param type $per_id
     * @return type
     */
    public function getCargosAppPersona($per_id) {
//SELECT * FROM t_cargoaap tcapp
//where tcapp.est_id ="1" and  tcapp.cap_id not in (Select tem.cap_id from t_empleado tem where tem.per_id=1500 )
        $command = Yii::app()->db->createCommand()
                ->select("*")
                ->from("t_cargoaap tcapp")
                ->where("tcapp.est_id =:est_id AND tcapp.cap_id not in (Select tem.cap_id from t_empleado tem where tem.per_id=:per_id)");
        $command->bindValues(array(
            ':per_id' => $per_id,
            ':est_id' => "1",
        ));
        $command->order("tcapp.cap_descripcion");
        $result = $command->queryAll();
        return ($result);
    }

}
